package com.tiankong.ware.controller;


import com.tiankong.ware.entity.PurchaseDetail;
import com.tiankong.ware.service.PurchaseDetailService;
import net.youdi.common.filter.PageFilter;
import net.youdi.common.model.Page;
import net.youdi.common.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

/**
 * <p>
 *  采购需求
 * </p>
 *
 * @author scl
 * @since 2021-03-22
 */
@RestController
@RequestMapping("/purchasedetail")
public class PurchaseDetailController {
    @Autowired
    private PurchaseDetailService purchaseDetailService;

    @GetMapping("list/page")
    public Result listPage(PageFilter filter){
        Page page = purchaseDetailService.queryPage(filter);
        return Result.ok().setPage(page);
    }
    @GetMapping("info/{id}")
    public Result info(@PathVariable("id") Long id){
        PurchaseDetail purchaseDetail = purchaseDetailService.getById(id);
        return Result.ok(purchaseDetail);
    }
    @PostMapping("save")
    public Result save(@RequestBody PurchaseDetail purchaseDetail){
        purchaseDetailService.saveOrUpdate(purchaseDetail);
        return Result.ok(purchaseDetail);
    }

    @DeleteMapping("delete")
    public Result delete(@RequestBody Set<Long> ids){
        purchaseDetailService.removeByIds(ids);
        return Result.ok();
    }


}
